package com.cr.sharding.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.cr.sharding.entity.User;
import com.cr.sharding.service.UserService;

/** 
* @author locket 
* @date 2019年12月13日 下午2:37:29 
* @version 1.0 
* @parameter  
* @since  
* @return  
*/
@RestController
@RequestMapping(value = "/user")
public class UserController {
    @Autowired
    UserService userService;
    
    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public String add(){
        for (Integer i = 10000;i<20000;i++) {
            User u = new User();
            u.setId(Long.parseLong(i.toString()));
            u.setLoginName("test" + i);
            u.setName("name" + i);
            u.setPhone("1301111" + i);
            Long ireturn = userService.add(u);
            System.out.println(ireturn);
        }
        return "ok";
    }
    
    @RequestMapping(value = "/info", method = RequestMethod.GET)
    public User info(User user) {
        User u = userService.info(user);
        return u;
    }
    
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public List<User> list(User user) {
        List<User> lst = userService.list(user);
        return lst;
    }
}
